package org.wyn.mongodb.dao.impl;

import org.bson.types.ObjectId;
import org.wyn.mongodb.bean.UserStatus;
import org.wyn.mongodb.common.SearchBDProvider;

import com.google.code.morphia.dao.BasicDAO;
/**
 * 用户状态mongodb实现层
 * @author wyn
 *
 */
public class UserStatusDao extends BasicDAO<UserStatus,ObjectId>{
	public UserStatusDao(){
		super(SearchBDProvider.getInstance());
	}
	/**
	 * 发布状态
	 * @param userName 发布者userName
	 * @param content 状态内容
	 * @return 成功true 失败false
	 */
	public boolean publishStatus(String userName,String content){
		UserStatus us = new UserStatus();
		us.setUserName(userName);
		us.setContent(content);
		us.setCreateTime(System.currentTimeMillis());
		save(us);
		ensureIndexes();
		return true;
	}
	/**
	 * 发布状态
	 * @param userName 发布者userName
	 * @param realName 发布者真实姓名
	 * @param portrait 发布者头像
	 * @param content 状态内容
	 * @return 成功true 失败false
	 */
	public boolean publishStatus(String userName,String realName,ObjectId portrait,String content){
		UserStatus us = new UserStatus();
		us.setUserName(userName);
		us.setRealName(realName);
		us.setPortrait(portrait);
		us.setContent(content);
		us.setCreateTime(System.currentTimeMillis());
		save(us);
		ensureIndexes();
		return true;
	}
}
